﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Library.Web.ViewModels.BookDetailsViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Details
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <%: Html.Hidden("BookId", Model.Book.Id) %>

    <h2><%: Model.Book.Title %></h2><b />
    <h3><%: Model.Book.Authors %></h3>
    <hr />
    
    <div class="section section-right-border" style="height:350px" >
        <% if (string.IsNullOrEmpty(Model.Book.ImageUrl)) { %>
            <img src="<%: Url.Content("~/Content/Images/empty-book.jpg") %>" alt="book pictue" width="250" />
        <% } else { %>
            <img src="<%: Model.Book.ImageUrl %>" alt="book pictue" width="250" />
        <% } %>
    </div>

    <div class="section section-right-border" style="width:350px; height:350px; text-align:justify;">
        <h3 class="section-title">Details</h3>
        <div class="book-details">
            <p>
            Understanding the philosophy and architecture of .NET is important for any Microsoft developer. The .NET Framework is not an abstract programming model. 
            </p>
            <p>
            It is a full-featured system that allows developers to implement their solutions and then make them available to other developers in a robust and secure environment. 
            <p>
            This book shows developers how to produce generic frameworks, libraries, classes, and tools to be used in the .NET Framework. 
            </p>
            <p>
            It also shows how to use the right language to develop parts of a system and then incorporate these parts together at runtime regardless of language differences. 
            </p>
            The book will conclude with a series of appendices from contributors who are very active in the .NET community.
        </div>
    </div>

    <div class="section">
        <h3 class="section-title">Book status</h3>        
        <% Html.RenderPartial("_PartBookStatus",
               new Library.Web.Models.BookStatus
               {
                     IsLoaned = Model.Book.IsLoaned,
                     LoanDate = Model.Book.LoanDate ?? default(DateTime),
                     LoanedBy = Model.Book.LoanedBy
               }); %>
    </div>

    <div>
        <h3 class="section-title">Comments</h3>

        <% if (Model.BookComments != null) { %>
           
           <% for (int p = 1; p <= Model.BookComments.TotalPages; p++) { %>
                <%: Ajax.ActionLink("Page " + p, "GetBookComments", 
                    new { bookId = Model.Book.Id, pageNumber = p}, 
                    new AjaxOptions { 
                        UpdateTargetId = "bookCommentsResult", 
                        LoadingElementId="commentsLoading" })%> 
                    
                    <span> | </span>
           <%} %>

           <span id="commentsLoading" style="display:none;">Loading...</span>

           <br />
           <br />
           
           <div id="bookCommentsResult">
<%--               <% foreach(var comment in Model.BookComments.Result){ %>
                    <% Html.RenderPartial("BookComments", comment); %>
               <%} %>--%>

                <% Html.RenderPartial("BookComments", Model.BookComments.Result); %>
           </div>


        <% } else {%>
            <div>
                No comments found.
            </div>
        <% } %>
        
    </div>

</asp:Content>
